/**
 * BASIC AND EASY, BUT FUNNY :)
 */
package  
{
	import flare.basic.*;
	import flare.core.*;
	import flare.loaders.collada.*;
	import flash.display.*;
	import flash.events.*;
	
	[SWF(frameRate = 120, backgroundColor = 0x808080, width = 800, height = 600 )]
	/**
	 * ...
	 * @author Ariel Nehamd
	 */
	public class Test02 extends Sprite
	{
		private var scene:Scene3D;
		private var model:Pivot3D;
		
		public function Test02() 
		{
			ColladaLoader.texturesFolder = "textures"; // <--needed for collada.
			
			scene = new Scene3D( this );
			scene.camera.setPosition( 0, 0, -150 );
			
			model = scene.addChildFromFile( "test1.dae" );
			
			scene.addEventListener( Scene3D.PROGRESS_EVENT, progressEvent );
			scene.addEventListener( Scene3D.COMPLETE_EVENT, completeEvent );
			
			// we can access to the model pivot before it loaded his content.
			scene.addEventListener( Scene3D.UPDATE_EVENT, updateEvent );
		}
		
		private function progressEvent(e:Event):void 
		{
			// at the moment, the value it not presice if it has textures.
			// we are using the same "scene.resources" context for all files now.
			// first we load the DAE file, then all textures.
			trace( scene.loadProgress );
		}
		
		private function completeEvent(e:Event):void 
		{
			trace( "load completed" );
		}
		
		private function updateEvent(e:Event):void 
		{
			model.rotateY( 2 );
			model.rotateX( 1 );
		}
		
	}

}